{
 "metadata": {},
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Mayavi: Install python stuff from source\n",
      "======================================================================\n",
      "\n",
      "Following <http://www.enthought.com/enthought/wiki/GrabbingAndBuilding>,\n",
      "you have to build/install VTK 5.0 and a few python extensions from\n",
      "sources.\n",
      "\n",
      "All needed installation information for a given python module or VTK can\n",
      "be reached on its webpage.\n",
      "\n",
      "For the impatient, these informations are resumed here.\n",
      "\n",
      "Note about configure script: If you don't specify the destination where\n",
      "the packages will be installed, they will be installed by defaut in\n",
      "/usr/local.\n",
      "\n",
      "We make the choice here to install them in a personnal directory, say\n",
      "\\~/Mayavi2. So we set the environment variable DESTDIR to \\~/Mayavi2,\n",
      "and will refer it later as DESTDIR:\n",
      "\n",
      "Under sh shell-like, type:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "export DESTDIR=~/Mayavi2"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Under csh shell-like, type:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "setenv DESTDIR ~/Mayavi2"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Is is also supposed that you download and uncompress all tarball sources\n",
      "in a specific directory, named src/, for example.\n",
      "\n",
      "### Installing python2.3/python2.4\n",
      "\n",
      "Download Python-2.3.5.tar.bz2 at\n",
      "<http://www.python.org/download/releases/2.3.5> or Python-2.4.3.tar.bz2\n",
      "at <http://www.python.org/download/releases/2.4.3> and untar it in src/:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "cd src && tar xvfj Python-2.4.3.tar.bz2"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Then run:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "cd Python-2.4.3/ && ./configure --enable-shared --enable-unicode=ucs4 --prefix=$DESTDIR"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Then you can make & make install:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "make && make install"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "### Installing VTK 5.0\n",
      "\n",
      "Download vtk-5.0.0.tar.gz and vtkdata-5.0.0.tar.gz at\n",
      "<http://public.kitware.com/VTK/get-software.php> and untar them in src/:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "cd src/ && tar xvfz vtk-5.0.0.tar.gz && tar xvfz vtkdata-5.0.0.tar.gz"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Note: cmake package must be installed before proceed.\n",
      "\n",
      "Run:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "cd VTK && ccmake ."
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "to create the required Makefile.\n",
      "\n",
      "Press on \"c\" to configure.\n",
      "\n",
      "Then press \"enter\" on the selected item to toggle flag.\n",
      "\n",
      "You should specify some information, notably about some libraries\n",
      "location (tcl/tk libs + dev packages and python2.3/python2.4 you have\n",
      "just installed) if ccmake does not find them, and the destination (set\n",
      "it to DESTDIR).\n",
      "\n",
      "Don't forget to set flag \"VTK\\_WRAP\\_PYTHON\" to on (and \"VTK\\_WRAP\\_TCL\"\n",
      "if you want to use Tcl/Tk):"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "BUILD_EXAMPLES                   ON\n",
      "BUILD_SHARED_LIBS                ON\n",
      "CMAKE_BACKWARDS_COMPATIBILITY    2.0\n",
      "CMAKE_BUILD_TYPE\n",
      "CMAKE_INSTALL_PREFIX             DESTDIR\n",
      "VTK_DATA_ROOT                    DESTDIR/VTKData\n",
      "VTK_USE_PARALLEL                 OFF\n",
      "VTK_USE_RENDERING                ON\n",
      "VTK_WRAP_JAVA                    OFF\n",
      "VTK_WRAP_PYTHON                  ON\n",
      "VTK_WRAP_TCL                     ON"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Press \"c\" to continue configuration:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "PYTHON_INCLUDE_PATH             *DESTDIR/include/python2.4\n",
      "PYTHON_LIBRARY                  *DESTDIR/lib/libpython2.4.so\n",
      "TCL_INCLUDE_PATH                */usr/include/tcl8.4\n",
      "TCL_LIBRARY                     */usr/lib/libtcl8.4.so                                            \n",
      "TK_INCLUDE_PATH                 */usr/include/tcl8.4\n",
      "TK_LIBRARY                      */usr/lib/libtk8.4.so\n",
      "VTK_USE_RPATH                   *OFF\n",
      "BUILD_EXAMPLES                   ON\n",
      "BUILD_SHARED_LIBS                ON\n",
      "CMAKE_BACKWARDS_COMPATIBILITY    2.0\n",
      "CMAKE_BUILD_TYPE                 \n",
      "CMAKE_INSTALL_PREFIX             DESTDIR\n",
      "VTK_DATA_ROOT                    DESTDIR/VTKData\n",
      "VTK_USE_PARALLEL                 OFF\n",
      "VTK_USE_RENDERING                ON\n",
      "VTK_WRAP_JAVA                    OFF\n",
      "VTK_WRAP_PYTHON                  ON\n",
      "VTK_WRAP_TCL                     ON"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Note: you can press \"t\" to get more configuration options.\n",
      "\n",
      "Press \"c\" and then \"g\" to exit configuration, then type:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "make && make install"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "### Installing wx-Python2.6\n",
      "\n",
      "Download wxPython-src-2.6.3.2.tar.gz at\n",
      "<https://sourceforge.net/project/showfiles.php?group_id=10718> and untar\n",
      "it in src/:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "cd src/ && tar xvfz wxPython-src-2.6.3.2.tar.gz"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Note: You should have GTK 2 installed i.e. you should have libgtk-2.6.\\*\n",
      "\\`and\\` libgtk2.6.\\*-dev packages installed.\n",
      "\n",
      "Then run:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "cd wxPython-src-2.6.3.2/ && ./configure --enable-unicode --with-opengl --prefix=$DESTDIR"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Then you can do:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "make; make -C contrib/src/animate; make -C contrib/src/gizmos; make -C contrib/src/stc"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "or follow instructions on wx-Python2.6 webpage, creating a little script\n",
      "which runs automatically the commands above.\n",
      "\n",
      "Then install all:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "make install; make -C contrib/src/animate install ; make -C contrib/src/gizmos install; make -C contrib/src/stc install"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "To build python modules:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "cd wxPython"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "and run:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "./setup.py build_ext --inplace --debug UNICODE=1"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "and install them:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "./setup.py install UNICODE=1 --prefix=$DESTDIR"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "### Installing scipy 0.5 & numpy 1.0\n",
      "\n",
      "Download scipy-0.5.1.tar.gz at <http://www.scipy.org/Download>\n",
      "\n",
      "Before installing scipy, you have to download and install:\n",
      "\n",
      "`*\u00a0numpy-1.0.tar.gz\u00a0(http://sourceforge.net/project/showfiles.php?group_id=1369&package_id=175103)`\n",
      "\n",
      "`*\u00a0Atlas\u00a0libraries\u00a0(you\u00a0could\u00a0install\u00a0it\u00a0with\u00a0your\u00a0packages\u00a0manager,\u00a0no\u00a0need\u00a0to\u00a0build\u00a0it\u00a0in\u00a0src/)`\n",
      "\n",
      "No special option are required to install these python extensions.\n",
      "\n",
      "To install these packages in our \\$DESTDIR, simply change directory and\n",
      "type:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "./setup.py install --prefix=$DESTDIR"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "### That's all, folks !\n",
      "\n",
      "Before installing !MayaVi2, you have to set some environment variables,\n",
      "to tell !MayaVi2 where python extensions can be found.\n",
      "\n",
      "Under sh shell-like, type:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "export PYTHONPATH=$DESTDIR:$PYTHONPATH\n",
      "export LD_LIBRARY_PATH=$DESTDIR:$LD_LIBRARY_PATH"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Under csh shell-like, type:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "setenv PYTHONPATH ${DESTDIR}:${PYTHONPATH}\n",
      "setenv LD_LIBRARY_PATH ${DESTDIR}:${LD_LIBRARY_PATH}"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}